from flask import Flask,session

app = Flask(__name__)

#设置session的盐
app.secret_key = 'asdfdadf'

# #类
# class DefaultConfig:
#     SECRET_KEY = 'sdfsfs'
# app.config.from_object(DefaultConfig)

@app.route('/set_session/')
def set_session():
    #session['key'] = value
    session['uname'] = 'itbaizhan'
    session['pwd'] = '123456'
    return '设置session信息'

@app.route('/get_session/')
def get_session():
    uname = session.get('uname')
    pwd = session.get('pwd')
    return f'获取session信息:{uname}=={pwd}'

@app.route('/del_session/')
def del_session():
    #POP删除一个key
    session.pop('uname')
    #clear删除所有的数据
    # session.clear()
    return '删除session信息'
@app.route('/')
def index():
    return "Hello"

if __name__ == '__main__':
    app.run(debug=True)